from flask import Blueprint, request
from ..services.rabbitmq_service import create_queue, send_message

rabbitmq_bp = Blueprint('rabbitmq', __name__)


@rabbitmq_bp.route('/create_queue', methods=['POST'])
def create_queue_route():
    data = request.get_json()
    queue_name = data.get('queue_name')
    if not queue_name:
        return "Queue name is required.", 400
    return create_queue(queue_name)


@rabbitmq_bp.route('/send_message', methods=['POST'])
def send_message_route():
    data = request.get_json()
    queue_name = data.get('queue_name')
    message = data.get('message')
    if not queue_name or not message:
        return "Queue name and message are required.", 400
    return send_message(queue_name, message)
